import { director, ISchedulable, Scheduler } from "cc";


export class TimerMgr {

    init() {
    }
    finit() {
    }

    setInterval(handler: (dt?: number) => void, timeOut: number, target: ISchedulable, ...args: any[]): void {
        // setInterval(handler,timeOut,args);
        Scheduler.enableForTarget(target);
        return director.getScheduler().schedule(handler, target, timeOut)
    }

    clearInterval(callback: Function, target: ISchedulable): void {
        director.getScheduler().unschedule(callback, target);
    }

    setTimeOut(handler: (dt?: number) => void, timeOut: number, target: ISchedulable, ...args: any[]): void {
        // setTimeout(handler,timeout,args)
        return director.getScheduler().schedule(handler, target, timeOut, 0);

    }

    clearTimeOut(callback: Function, target: ISchedulable): void {
        director.getScheduler().unschedule(callback, target);
    }
}